您的訂閱是我製作影片的動力
訂閱點這裡~
影片程式碼
library(naniar)
data(iris)
any_na(iris) #前置1: chk NA
iris <- iris[,-5]
iris <- scale(iris) #前置2: standard norm 標準化
## k-means ####
#沒寫大多為歐式
library(ClusterR) # WCSS 組內平方和 = SSE = SSW,WCSSE sum(WCSS)
opt_km = Optimal_Clusters_KMeans(iris, max_clusters = 10, initializer = 'random',
criterion = "WCSSE",plot_clusters = T)# random
km = KMeans_rcpp(iris, clusters = 4, num_init = 5,
max_iters = 100, initializer = 'random') # random
km$WCSS_per_cluster
km_out <- as.data.frame(km$clusters)
final <- cbind(iris,km_out)
若內容有誤,還請留言指正,謝謝您的指教